<template>
  <div>
    <el-dialog :visible.sync="visible"
               :title="title"
               width="60%"
               :append-to-body="true"
               :before-close="modalClose"
               :close-on-click-modal="false"
               :close-on-press-escape="false">
      <el-form :model="submitData"
               label-position="right"
               label-width="180px"
               ref="formModelRef"
               :rules='formModelRules'>
        <el-form-item label="请选择项目所处分类：" prop="healthRiskTypeId">
          <el-select v-model="submitData.healthRiskTypeId"
                     @change="handleChangeType"
                     style="width: 260px"
                     placeholder="项目所处分类">
            <el-option v-for="item in typeList"
                       :key="item.id"
                       :label="item.name"
                       :value="item.id">
            </el-option>
          </el-select>

        </el-form-item>

        <el-form-item label="请选择项目：" prop="healthCheckPackageId">
          <el-select v-model="submitData.healthCheckPackageId"
                     style="width: 260px"
                     @change="handleChangeProject"
                     placeholder="项目">
            <el-option v-for="item in projectList"
                       :key="item.id"
                       :label="item.name"
                       :value="item.id">
            </el-option>
          </el-select>

        </el-form-item>

        <el-form-item label="请选择服务选项：" prop="healthCheckPackageItemId" v-if="priceList.length>0">
          <el-radio-group v-model="submitData.healthCheckPackageItemId" @change="handleChangePrice">
            <el-radio v-for="(item,index) in priceList" :label="item.id" :key="index">{{item.detectName}}{{ item.price }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="专享价:" required>
          <el-input placeholder="第一月"
                    v-model="submitData.priceDtos[0].vipPrice"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>
          <el-input placeholder="第二月"
                    v-model="submitData.priceDtos[1].vipPrice"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>
          <el-input placeholder="第三月至第十二月"
                    v-model="submitData.priceDtos[2].vipPrice"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>
        </el-form-item>


        <el-form-item label="签单红包:" required>
          <el-input placeholder="第一月"
                    v-model="submitData.priceDtos[0].reward"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>
          <el-input placeholder="第二月"
                    v-model="submitData.priceDtos[1].reward"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>

          <el-input placeholder="第三月至第十二月"
                    v-model="submitData.priceDtos[2].reward"
                    class="w-200"
                    clearable>
            <el-button slot="append">元</el-button>
          </el-input>

        </el-form-item>
        <el-form-item label="服务医院：">
          <el-select v-model="submitData.hospital"
                     clearable
                     filterable
                     style="width: 260px"
                     placeholder="服务医院">
            <el-option v-for="item in hospitals"
                       :key="item.hospitalId"
                       :label="item.name"
                       :value="item.hospitalId">
            </el-option>
          </el-select>
          <el-button type="primary" @click="handleAddHospital(submitData.hospital)">增加</el-button>
        </el-form-item>


        <el-form-item label="已选医院：" v-if="submitData.serviceHospitalDtos&&submitData.serviceHospitalDtos.length>0">
          <el-table
            :data="submitData.serviceHospitalDtos"
            style="width: 100%;"
            border>
            <el-table-column label="医院名称" align="center">
              <template slot-scope="scope">{{ scope.row.name }}</template>
            </el-table-column>
            <el-table-column label="医院网址" align="center">
              <template slot-scope="scope">
                <el-input v-model="scope.row.website"></el-input>
              </template>
            </el-table-column>

            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button size="mini"
                           type="danger"
                           :disabled="vipData.compayid==scope.row.id&&organization=='hospital'"
                           @click="handleDel(scope.$index, scope.row)">
                  删除
                </el-button>
                <el-button size="mini"
                           type="primary"
                           @click="handleEdit(scope.$index, scope.row)">
                  编辑
                </el-button>

              </template>
            </el-table-column>

          </el-table>
        </el-form-item>

        <el-form-item label="临床意义:">
          <div>
            <vue-neditor-wrap :destroy="true"
                              v-model="submitData.indicationClinicalSignificance"
                              :config="myConfig"></vue-neditor-wrap>
          </div>

        </el-form-item>
        <el-form-item label="分析医生：">
          <el-input placeholder="请输入该医生的平台账号"
                    v-model="submitData.fenxiuser"
                    style="width: 260px"
                    clearable>
          </el-input>
          <el-button type="primary" @click="handleAddFenxiDoctor()">增加</el-button>
        </el-form-item>


        <el-form-item v-if="submitData.recheckDoctorDtos.length>0">
          <el-table
            :data="submitData.recheckDoctorDtos"
            style="width: 100%;"
            border>
            <el-table-column label="医生姓名" align="center">
              <template slot-scope="scope">{{ scope.row.nickName }}</template>
            </el-table-column>
            <el-table-column label="平台账号" align="center">
              <template slot-scope="scope">{{ scope.row.loginName }}</template>
            </el-table-column>
            <el-table-column label="所在科室" align="center">
              <template slot-scope="scope">{{ scope.row.departmentName }}</template>
            </el-table-column>
            <el-table-column label="职级" align="center">
              <template slot-scope="scope">{{ scope.row.doctorTitleName }}</template>
            </el-table-column>
            <el-table-column label="所属医院" align="center">
              <template slot-scope="scope">{{ scope.row.hospitalName }}</template>
            </el-table-column>
            <el-table-column label="所属医联体" align="center">
              <template slot-scope="scope">{{ scope.row.medicalName }}</template>
            </el-table-column>
            <el-table-column label="分析费用" align="center" width="200px">
              <template slot-scope="scope">
                <el-input placeholder="请输入分析费用"
                          v-model="scope.row.price"
                          style="width: 160px"
                          clearable>
                </el-input>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button size="mini"
                           type="danger"
                           @click="handleDelFenxiDoctor(scope.$index, scope.row)">
                  删除
                </el-button>

              </template>
            </el-table-column>

          </el-table>

        </el-form-item>


        <el-form-item label="复核医生：">
          <el-input placeholder="请输入该医生的平台账号"
                    v-model="submitData.fuheuser"
                    style="width: 260px"
                    clearable>
          </el-input>
          <el-button type="primary" @click="handleAddFuheDoctor()">增加</el-button>
        </el-form-item>


        <el-form-item v-if="submitData.checkDoctorDtos.length>0">
          <el-table
            :data="submitData.checkDoctorDtos"
            style="width: 100%;"
            border>
            <el-table-column label="医生姓名" align="center">
              <template slot-scope="scope">{{ scope.row.nickName }}</template>
            </el-table-column>
            <el-table-column label="平台账号" align="center">
              <template slot-scope="scope">{{ scope.row.loginName }}</template>
            </el-table-column>
            <el-table-column label="所在科室" align="center">
              <template slot-scope="scope">{{ scope.row.departmentName }}</template>
            </el-table-column>
            <el-table-column label="职级" align="center">
              <template slot-scope="scope">{{ scope.row.doctorTitleName }}</template>
            </el-table-column>
            <el-table-column label="所属医院" align="center">
              <template slot-scope="scope">{{ scope.row.hospitalName }}</template>
            </el-table-column>
            <el-table-column label="所属医联体" align="center">
              <template slot-scope="scope">{{ scope.row.medicalName }}</template>
            </el-table-column>
            <el-table-column label="复核费用" align="center" width="200px">
              <template slot-scope="scope">
                <el-input placeholder="请输入复核费用"
                          v-model="scope.row.price"
                          style="width: 160px"
                          clearable>
                </el-input>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template slot-scope="scope">
                <el-button size="mini"
                           type="danger"
                           @click="handleDelFuheDoctor(scope.$index, scope.row)">
                  删除
                </el-button>

              </template>
            </el-table-column>

          </el-table>

        </el-form-item>
        <el-form-item label="套餐包数量：">
          <el-radio-group v-model="submitData.isFlowSignMonth">
            <el-radio :label="1">跟随签约包月份</el-radio>
            <el-radio :label="0">固定数量</el-radio>
          </el-radio-group>

        </el-form-item>
        <el-form-item v-if="submitData.isFlowSignMonth==0" prop="fixMonth" label="数量："
                      :rules="submitData.isFlowSignMonth==0?formModelRules.fixMonth:[{required: false}]">
          <el-input placeholder="请输入数量"
                    v-model.number="submitData.fixMonth"
                    type="number"
                    style="width: 260px"
                    clearable>
          </el-input>
        </el-form-item>

      </el-form>
      <p align="center">
        <el-button @click="modalClose"
                   type="info">取 消
        </el-button>
        <el-button type="primary"
                   v-prevent-re-click
                   @click="handleSubmit()">确 认
        </el-button>
      </p>
    </el-dialog>

    <el-dialog title="编辑医院"
               :visible.sync="showHospitalDialog"
               :append-to-body="true"
               :close-on-click-modal="false"
               :close-on-press-escape="false"
               width="60%">
      <el-form :model="teamDto"
               label-position="right"
               label-width="180px">
        <el-form-item label="医院名称：">
          <p>{{ teamDto.hospitalName }}</p>
        </el-form-item>
        <el-form-item label="服务团队介绍：">
          <el-input placeholder="请输入服务团队介绍"
                    v-model="teamDto.info"
                    style="width: 360px"
                    type="textarea"
                    clearable>
          </el-input>
        </el-form-item>

        <el-form-item label="服务权重：">
          <el-input placeholder="请输入服务权重"
                    v-model="teamDto.orderWeight"
                    style="width: 200px"
                    clearable>
            <el-button slot="append">%</el-button>
          </el-input>
        </el-form-item>


        <el-form-item label="专家介绍：">
          <el-button type="primary" @click="handleAddProfessor">添加专家</el-button>
        </el-form-item>

        <!--        专家列表-->
        <el-form-item v-for="(item,index) in teamDto.expertDtos " label-width="100px" :key="item">

          <el-form-item label="专家姓名：">
            <el-input placeholder="请输入专家姓名"
                      v-model="item.name"
                      style="width:260px"
                      clearable>
            </el-input>
            <el-button type="danger" @click="handleDelProfessor(index)">删 除</el-button>
          </el-form-item>

          <el-form-item label="专家头像：">
            <img :src="item.imageUrl"
                 width="100px"
                 height="100px"
                 style="border-radius: 5%"/>
            <Upload :action="fileLogoUploadAction"
                    :max-size="fileMaxSize"
                    :show-file-list="false"
                    :on-exceeded-size="showError"
                    :on-success="uploadLogoSuccess">
              <el-button icon="ios-cloud-upload-outline" @click="handleUpImage(index)">请上传专家头像</el-button>
            </Upload>
          </el-form-item>

          <el-form-item label="专家介绍：">
            <el-input placeholder="请输入专家介绍"
                      v-model="item.info"
                      style="width: 360px"
                      type="textarea"
                      clearable>
            </el-input>
          </el-form-item>

        </el-form-item>
      </el-form>
      <p align="center">
        <el-button type="primary"
                   @click="handleSaveHospital">确 认
        </el-button>
        <el-button @click="showHospitalDialog=false"
                   style="margin-left: 8px">取 消
        </el-button>
      </p>

    </el-dialog>
  </div>
</template>

<script>
import ElementTable from '@/base/ElementTable'
import VueNeditorWrap from 'vue-neditor-wrap'

export default {
  name: "vipDialog",
  props: {
    vipData: {
      type: Object,
      default: {}
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {

      title: '新 增',
      loading: false,
      showHospitalDialog: false,
      imageIndex: 0,
      teamDto: {
        hospitalName: '',
        info: '',
        orderWeight: '',
        expertDtos: [],
      },
      hospitalIndex: 0,
      fileLogoUploadAction: '',
      fileMaxSize: 1024 * 50,
      priceDtos: [{
        vipPrice: '',//专享价
        reward: '',//签到红包
        month: '1',
      }, {
        vipPrice: '',//专享价
        reward: '',//签到红包
        month: '2',
      }, {
        vipPrice: '',//专享价
        reward: '',//签到红包
        month: '3',
      }],
      submitData: {
        id: '',
        companyId: '',
        hospitalId: '',
        healthRiskTypeId: '',//类别id
        healthRiskTypeName: '',//类别名称
        healthCheckPackageId: '',//项目id
        healthCheckPackageItemId: '',//价格id

        priceDtos: [
          {
            vipPrice: '',//专享价
            reward: '',//签到红包
            month: '1',
          }, {
            vipPrice: '',//专享价
            reward: '',//签到红包
            month: '2',
          }, {
            vipPrice: '',//专享价
            reward: '',//签到红包
            month: '3',
          }
        ],
        serviceHospitalDtos: [],//服务医院
        indicationClinicalSignificance: '',//临床意义
        isAllCheckDoctor: 0,//分析医生选项
        recheckDoctorDtos: [],//指定分析医生
        isAllRecheckDoctor: 0,//复核医生选项
        checkDoctorDtos: [],//复核医生选项
        hospital: '',
        fenxiuser: '',
        fuheuser: '',
        isFlowSignMonth: 1,//是否跟随月份
        fixMonth: '',//固定数量

      },
      typeList: [],//项目分类
      projectList: [],//项目
      priceList: [],//项目
      hospitals: [],
      myConfig: {
        // 你的UEditor资源存放的路径,相对于打包后的index.html
        UEDITOR_HOME_URL: this.api.uEditorHomeUrl,
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: '418',
        // 初始容器宽度
        initialFrameWidth: '100%',
        // 关闭自动保存
        enableAutoSave: false,
        scaleEnabled: true
      },
      formModelRules: {
        healthRiskTypeId: [
          {required: true, message: '请选择项目分类'}
        ],
        healthCheckPackageId: [
          {required: true, message: '请选择项目'}
        ],
        healthCheckPackageItemId: [
          {required: true, message: '请选择服务项'}
        ],
        fixMonth: [
          {required: true, message: '请输入1到12的整数'},
          {type: 'number'},
          {pattern: /^([1-9]|1[012])$/, message: '请输入1到12的整数', tigger: 'blur'},
        ]
      },
      organization: ''
    }
  },
  created() {
    this.fileLogoUploadAction = this.api.file.upload;
    this.organization = this.vipData.organization

    if (this.vipData.vipid) {
      this.title = '编 辑'
      this.submitData.id = this.vipData.vipid
      this.getHealthCheckDetail()
    } else {
      this.title = '新 增'
      this.submitData = {
        id: '',
        companyId: '',
        hospitalId: '',
        healthRiskTypeId: '',//类别id
        healthRiskTypeName: '',//类别名称
        healthCheckPackageId: '',//项目id
        healthCheckPackageItemId: '',//价格id
        priceDtos: [{
          vipPrice: '',//专享价
          reward: '',//签到红包
          month: '1',
        }, {
          vipPrice: '',//专享价
          reward: '',//签到红包
          month: '2',
        }, {
          vipPrice: '',//专享价
          reward: '',//签到红包
          month: '3',
        }],
        serviceHospitalDtos: [],//服务医院
        indicationClinicalSignificance: '',//临床意义
        isAllCheckDoctor: 1,//分析医生选项
        recheckDoctorDtos: [],//指定分析医生
        isAllRecheckDoctor: 1,//复核医生选项
        checkDoctorDtos: [],//复核医生选项
        hospital: '',
        fenxiuser: '',
        fuheuser: '',
        isFlowSignMonth: 1,//是否跟随月份
        fixMonth: '',//固定数量
      }
      this.getHealthRiskTypeList()
      if (this.organization === 'hospital') {
        this.submitData.serviceHospitalDtos.push({
          name: this.vipData.name,
          id: this.vipData.compayid,
          website: ''
        })
      }
    }
    if (this.organization === 'hospital') {
      this.submitData.hospitalId = this.vipData.compayid
    } else if (this.organization === 'bclient') {
      this.submitData.companyId = this.vipData.compayid
    }

    this.getHospitalList()
  },
  methods: {
    modalClose() {
      this.$emit('update:visible', false); // 直接修改父组件的属性
    },
    //增加医院
    handleAddHospital(hospitalId) {
      if (hospitalId) {
        let list = this.submitData.serviceHospitalDtos;
        if (list.some(item => item.id == hospitalId)) {
          this.$message.error('该医院已存在')
          return
        }
        let filter = this.hospitals.filter(item => item.hospitalId == hospitalId)[0];
        list.push({
          name: filter.name,
          id: hospitalId,
          website: filter.website
        })
        this.submitData.hospital = ''
      } else {
        this.$message.error('请选择医院')
      }
    },
    //删除医院
    handleDel(index, row) {
      this.submitData.serviceHospitalDtos.splice(index, 1)
    },
    //编辑医院
    handleEdit(index, row) {
      this.hospitalIndex = index
      this.showHospitalDialog = true
      this.teamDto.hospitalName = row.name
      if (row.teamDto) {
        this.teamDto.info = row.teamDto.info
        this.teamDto.orderWeight = row.teamDto.orderWeight
        this.teamDto.expertDtos = row.teamDto.expertDtos
      } else {
        this.teamDto.info = ''
        this.teamDto.orderWeight = ''
        this.teamDto.expertDtos = []
      }

    },
    handleUpImage(index) {
      this.imageIndex = index
    },
    //上传图片错误
    showError(file, fileList) {
      this.$Notice.warning({
        title: '文件大小超限',
        desc: "文件  " + file.name + " 太大，上传文件大小不能超过100M."
      });
    },
    //上传成功
    uploadLogoSuccess(res) {
      if (res.code === '200') {
        this.$message.success('上传成功');
        // this.teamDto.imageUrl = res.object[0];
        this.teamDto.expertDtos[this.imageIndex].imageUrl = res.object[0]
      } else {
        this.$message.error('上传失败');
      }
    },
    //添加专家
    handleAddProfessor() {
      var expertDtos = this.teamDto.expertDtos;
      expertDtos.push({
        name: '',
        imageUrl: '',
        info: '',
      })
    },
    //删除专家
    handleDelProfessor(index) {
      this.teamDto.expertDtos.splice(index, 1)
    },
    //保存医院信息
    handleSaveHospital() {
      var newData = {
        teamDto: {
          hospitalName: '',
          info: '',
          orderWeight: '',
          expertDtos: ''
        }
      }
      //对象增加字段
      var serviceHospitalDto = this.submitData.serviceHospitalDtos[this.hospitalIndex];
      var assign = Object.assign(serviceHospitalDto, newData);
      assign.teamDto.info = this.teamDto.info
      assign.teamDto.orderWeight = this.teamDto.orderWeight
      assign.teamDto.expertDtos = this.teamDto.expertDtos
      assign.teamDto.hospitalName = this.teamDto.hospitalName
      this.submitData.serviceHospitalDtos[this.hospitalIndex] = assign

      this.showHospitalDialog = false
    },

    //增加分析医生
    handleAddFenxiDoctor() {
      if (this.submitData.fenxiuser) {
        //查询医生，如果查询到就添加，否则提示账号有误
        var serviceHospitalDtos = JSON.parse(JSON.stringify(this.submitData.serviceHospitalDtos));
        if (serviceHospitalDtos.length === 0) {
          this.$message.warning('请先添加服务医院')
        } else {
          var hids = serviceHospitalDtos.map(item => item.id);
          this.getDoctorInfo(this.submitData.fenxiuser, hids, 1)
        }


      } else {
        this.$message.error('请输入医生平台账号')
      }
    },
    //删除分析医生
    handleDelFenxiDoctor(index, row) {
      this.submitData.recheckDoctorDtos.splice(index, 1)
    },
    //增加复核医生
    handleAddFuheDoctor() {
      if (this.submitData.fuheuser) {
        //查询医生，如果查询到就添加，否则提示账号有误
        var serviceHospitalDtos = JSON.parse(JSON.stringify(this.submitData.serviceHospitalDtos));
        if (serviceHospitalDtos.length === 0) {
          this.$message.warning('请先添加服务医院')
        } else {
          var hids = serviceHospitalDtos.map(item => item.id);
          this.getDoctorInfo(this.submitData.fuheuser, hids, 2)
        }

      } else {
        this.$message.error('请输入医生平台账号')
      }
    },
    //删除复核医生
    handleDelFuheDoctor(index, row) {
      this.submitData.checkDoctorDtos.splice(index, 1)
    },
    //提交数据
    handleSubmit() {
      this.$refs.formModelRef.validate(async (valid) => {
        if (valid) {
          //服务价格列表
          let priceDtos = this.submitData.priceDtos;
          let healthCheckPackageItemId = this.submitData.healthCheckPackageItemId;
          let priceList = this.priceList;
          let price = priceList.find(item => item.id == healthCheckPackageItemId).price;

          let isExceed = priceDtos.some(item => item.vipPrice > price || item.reward > price)
          let isThePriceEmpty = priceDtos.every(item=>item.vipPrice&&item.reward);
          if (!isThePriceEmpty){
            this.$message.warning('请完善专享价和签单红包')
          }else {
            if (isExceed) {
              this.$message.warning('专享价和签单红包不能大于服务选项价格')
            }else if (this.submitData.isFlowSignMonth == 0 && this.submitData.fixMonth == '') {
              this.$message.warning('请输入固定数量')
            } else {
              // this.submitData.priceDtos = this.priceDtos
              this.saveCompanyVip()
            }
          }

        }
      })

    },
    //选择项目分类
    handleChangeType() {
      var healthRiskTypeId = this.submitData.healthRiskTypeId;
      if (healthRiskTypeId) {
        var typeList = this.typeList
        this.submitData.healthRiskTypeName = typeList.filter(item => item.id == healthRiskTypeId)[0].name
        this.submitData.healthCheckPackageId = ''
        this.priceList = []
        this.submitData.priceDtos.map(item => {
          item.reward = ''
          item.vipPrice = ''
        })
        this.getProject()
      }

    },
    //选择项目
    handleChangeProject() {
      var healthCheckPackageId = this.submitData.healthCheckPackageId;
      if (healthCheckPackageId) {
        this.priceList = []
        this.submitData.priceDtos.map(item => {
          item.reward = ''
          item.vipPrice = ''
        })
        this.getProjectPriceList()
      }
    },
    handleChangePrice() {
      this.submitData.priceDtos.map(item => {
        item.reward = ''
        item.vipPrice = ''
      })
    },
    //查询项目分类
    getHealthRiskTypeList() {
      this.post(this.api.company.getHealthRiskTypeList).then((res) => {
        if (res.data.code === '200') {
          this.typeList = res.data.object

        }
      })
    },
    //查询项目
    getProject() {
      this.post(this.api.company.getProject, {
        healthRiskTypeName: this.submitData.healthRiskTypeName,
        type: 1
      }).then((res) => {
        if (res.data.code === '200') {
          this.projectList = res.data.object
        }
      })
    },
    //查询项目对应价格
    getProjectPriceList() {
      this.post(this.api.company.getProjectPriceList, {
        id: this.submitData.healthCheckPackageId,
      }).then((res) => {
        if (res.data.code === '200') {
          this.priceList = res.data.object.itemList
          let detectList = this.priceList.map(item=>item.detectList);
          let nameArr=[]
          detectList.forEach(item=>{
            nameArr.push(item.map(v=>v.name))
          })
          this.priceList.forEach((item,index)=>{
            this.$set(item,'detectName',nameArr[index].join(','))
          })
          console.log('priceList------',this.priceList)
        }
      })
    },
    //查询合作医院
    getHospitalList() {
      this.post(this.api.company.getHospitalList, {
        pageSize: 50
      }).then((res) => {
        if (res.data.code === '200') {
          this.hospitals = res.data.object
        }
      })
    },
    //查询合作医院的医生
    getDoctorInfo(phone, hospitalIds, type) {
      this.post(this.api.company.getDoctorInfo, {
        phone: phone,
        hospitalIds: hospitalIds
      }).then((res) => {
        if (res.data.code === '200') {
          var bean = res.data.object[0]
          if (type == 1) {
            //分析医生
            var doctorlist = this.submitData.recheckDoctorDtos;
            doctorlist.push({
              nickName: bean.nickName,
              doctorId: bean.id,
              hospitalId: bean.hospitalId,
              loginName: bean.loginName,
              departmentName: bean.departmentName,
              doctorTitleName: bean.doctorTitleName,
              hospitalName: bean.hospitalName,
              medicalName: bean.medicalName,
            })
            this.submitData.fenxiuser = ''
          } else if (type == 2) {
            //复核医生
            var doctorlist = this.submitData.checkDoctorDtos;
            doctorlist.push({
              nickName: bean.nickName,
              doctorId: bean.id,
              hospitalId: bean.hospitalId,
              loginName: bean.loginName,
              departmentName: bean.departmentName,
              doctorTitleName: bean.doctorTitleName,
              hospitalName: bean.hospitalName,
              medicalName: bean.medicalName,
            })
            this.submitData.fuheuser = ''
          }
        } else {
          this.$message.warning('未查询到该医生')
        }
      })
    },
    //查询合作医院
    saveCompanyVip() {
      this.post(this.api.company.saveCompanyVip, this.submitData).then((res) => {
        if (res.data.code === '200') {
          this.$message.success('更新成功')
          this.modalClose()
          this.$parent.getList()
        }
      })
    },
    //vip详情
    getHealthCheckDetail() {
      this.post(this.api.company.getHealthCheckDetail, {
        id: this.vipData.vipid,
      }).then((res) => {
        if (res.data.code === '200') {
          this.submitData = Object.assign(this.submitData, res.data.object)
          this.submitData.healthRiskTypeName = res.data.object.healthRiskType.name
          // this.priceDtos = res.data.object.priceDtos

          this.submitData.checkDoctorDtos = this.submitData.checkDoctorDtos.map(item => ({
            nickName: item.doctorDto.nickName,
            doctorId: item.doctorDto.id,
            hospitalId: item.doctorDto.hospitalId,
            loginName: item.doctorDto.loginName,
            departmentName: item.doctorDto.departmentName,
            doctorTitleName: item.doctorDto.doctorTitleName,
            hospitalName: item.doctorDto.hospitalName,
            price: item.price,
            medicalName: item.medicalUnionNames
          }))
          this.submitData.recheckDoctorDtos = this.submitData.recheckDoctorDtos.map(item => ({
            nickName: item.doctorDto.nickName,
            doctorId: item.doctorDto.id,
            hospitalId: item.doctorDto.hospitalId,
            loginName: item.doctorDto.loginName,
            departmentName: item.doctorDto.departmentName,
            doctorTitleName: item.doctorDto.doctorTitleName,
            hospitalName: item.doctorDto.hospitalName,
            price: item.price,
            medicalName: item.medicalUnionNames
          }))
          this.getHealthRiskTypeList()
          this.getProject()
          this.getProjectPriceList()
        }
      })
    },

  },
  components: {
    'element-table': ElementTable,
    VueNeditorWrap
  }
}
</script>

<style scoped>

</style>
